package com.mercury.rabbitmq.listener;


import com.mercury.rabbitmq.base.BaseListener;
import com.mercury.rabbitmq.domain.RabbitMqMessage;
import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.*;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * topic 队列监听
 *
 * @author mercury
 */
@Component
@Slf4j
public class ManagerListener extends BaseListener {

    @Override
    protected void execute(RabbitMqMessage content) {
        log.info("execute success");
    }

    @Override
    protected void failExecute(RabbitMqMessage content) {
        log.info("execute fail");
    }


    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(value = "mercuryQueue", durable = "true"),
            exchange = @Exchange(value = "mercuryExchange", type = ExchangeTypes.TOPIC),
            key = "mercuryRoutingKey"))
    @Override
    protected void receiveMessage(Message message, Channel channel) throws IOException {
        super.receiveMessage(message, channel);
    }


}
